
#include    "cppsocket/udpnode.h"
#include    "cppsocket/stringbuffer.h"

using namespace CPPSocket;

static    int    sg_iPort = 3721;    
static    int    sg_iMaxTimes = 100;
   
int    main( int argc, char* argv[] )
{
    UDPNode    udper;
    
    udper.open();

    Address   server("127.0.0.1", sg_iPort);
    StringBuffer    request("Hello,World.");
    for(int i=0; i<sg_iMaxTimes; i++) {
        fprintf(stdout, "#%-8d request '%s' ...\n", i+1, request.c_str());
        udper.sendto(server, request);
        
        Address    address;
        StringBuffer    response;
        udper.recvfrom(address, response);
        fprintf(stdout, "#%-8d response '%s'.\n", i+1, response.c_str());
    }
        
    udper.close();
    
    return    0;
}

